<%@ page language="java" contentType="text/html; charset=UTF-8" import="java.util.*,java.text.*,
com.brother.model.*,com.ibatis.common.util.PaginatedList,com.brother.service.*,com.brother.*,java.io.*
,com.brother.util.DateFormatter"   pageEncoding="UTF-8"%><%

ReportService service = new ReportService();

Report report = (Report)session.getAttribute(Constants.REPORT_SEARCH_PARAMETERS);

PaginatedList pageData = service.findData("0", 20000,report);

response.reset();
response.setContentType("text/xml");
response.setHeader("Content-Disposition","attachment;filename=\"map.xml\"" ); 


String text = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"+
"<kml xmlns=\"http://www.opengis.net/kml/2.2\">\r\n"+
"<Document>\r\n"
  +"<name>KmlFile</name>\r\n"
  +"<Style id=\"transPurpleLineGreenPoly\">\r\n"
  +"<LineStyle>\r\n"
  +"<color>7F0000FF</color>\r\n"
  +"<width>3</width>\r\n"
  +"</LineStyle>\r\n"
  +"<PolyStyle>\r\n"
  +"<color>7F0000FF</color>\r\n"
  +"</PolyStyle>\r\n"
  +"</Style>\r\n"
  +"<Placemark>\r\n"
  +"<name>Tracker</name>\r\n"
  +"<visibility>1</visibility>\r\n"
  +"<description>History route</description>\r\n"
  +"<styleUrl>#transPurpleLineGreenPoly</styleUrl>\r\n"
  +"<LineString>\r\n"
  +"<tessellate>1</tessellate>\r\n"
  +"<altitudeMode>absolute</altitudeMode>\r\n"
  +"<coordinates>\r\n";
  
  StringBuffer sb = new StringBuffer(text);
  
  Iterator<Report> datas = pageData.iterator();   
  
  while(datas.hasNext()){
	  Report data = datas.next();
	  sb.append(data.getLng()+","+data.getLat()+"\r\n");
  }
  
        
        
      sb.append("</coordinates>\r\n"
        +"</LineString>\r\n"
        +"</Placemark>\r\n"
        +"</Document>\r\n"
        +"</kml>\r\n");

OutputStream   os=response.getOutputStream();   

os.write(sb.toString().getBytes("UTF-8"));

os.close();



%><%
com.brother.database.DataBase.closeThreadConnection();
%>